home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / FrexxEd / fpl / RCSControl.FPL < prev    next >
Encoding:
Text File  |  1996-09-27  |  6.8 KB  |  185 lines

  1. // $Id: RCSControl.FPL 1.11 1995/10/03 14:23:08 jskov Exp $
  2. // $VER: RCSControl.FPL 1.4 (04.10.95) © Jesper Skov $
  3.  
  4. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Check Out ««
  5. void export RCSCheckOut()
  6. {
  7.   int oldLine = ReadInfo("line");            // Grab cursor position
  8.   int oldByte = ReadInfo("byte_position");
  9.   int success=1;
  10.  
  11.   Status(0,"Checking out...");                // Tell user we're working
  12.   if (System("bin:co -l \""+ReadInfo("full_file_name")+"\"")){
  13.     success = 0;
  14.     if(Request("Check out error!\nProbably the file is already check out!\n(Consult the readme for more help)","RCS request","Force check out!|OK"))
  15.       if (System("bin:co -l -f \""+ReadInfo("full_file_name")+"\"")){
  16.         if(!Request("Check out error again!\nTry to check the file out by hand!\n(Consult the readme for more help)","RCS request","Sigh!|Just change that bloody w-flag, will ya'!")){
  17.           SetInfo(-1,"protection",ReadInfo("protection")+"w");
  18.           return;
  19.         }
  20.       } else
  21.         success=1;
  22.   }
  23.   if (success){
  24.     Status(0,"Reloading...");                // Tell user we're working
  25.     SetInfo(-1,"protection",ReadInfo("protection")+"w");
  26.     Load(ReadInfo("full_file_name"));        // Reload to get protection bit
  27.                                                // and ensure correct contents
  28.     GotoLine(oldLine, oldByte);                // Reposition cursor
  29.     CenterView();
  30.   }
  31. }
  32.  
  33. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Setup comment buffer ««
  34. void export EnterRCSComment(int ReLock)
  35. {
  36.   int RevisionID = New();                    // Make comment buffer
  37.   int OrgBuffer = CurrentBuffer(RevisionID);
  38.  
  39.   Rename("*RCS Comment*");                    // rename it
  40.   SetInfo(RevisionID, "_IsRCSBuffer", 1);    // and fill parent data
  41.   SetInfo(RevisionID, "_RCSParentBuffer", OrgBuffer);
  42.   SetInfo(RevisionID, "_RCSReLock", ReLock);
  43.   ReturnStatus("Press C-c C-c when comment is complete!");
  44. }
  45.  
  46.  
  47. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Check In ««
  48. void export RCSCheckIn()
  49. {
  50.   int ParentID = ReadInfo("_RCSParentBuffer");
  51.   int export thisID = CurrentBuffer(ParentID);
  52.   int reLock = ReadInfo("_RCSReLock",thisID);
  53.   string CommentName = "T:RCSComment"+itoa(thisID); // build temp name
  54.   string ParentName  = ReadInfo("full_file_name", ParentID); // get parent name
  55.   string lock = "-u";                        // How the file should be locked
  56.  
  57.   if (reLock)                                // If user wants to reLock,
  58.     lock = "-l";                            // change lock-mode.
  59.  
  60.   Save();                                    // Save parent buffer
  61.   CurrentBuffer(thisID);                    // and get back to comment buffer
  62.  
  63.   Rename(CommentName);                        // Rename
  64.   Save();                                    // and save comment buffer
  65.   CurrentBuffer(ParentID);                    // return control to parent
  66.  
  67.   Status(0,"Checking in...");                // Tell user we're working...
  68.  
  69.  
  70.   if (System("bin:ci "+lock+" \""+ParentName+"\" < "+CommentName)) // Check In
  71.     if(Request("Check in error!\nShould I try to check the file out first?\n(Consult the readme for more help)","RCS request","Yes|No!"))
  72.       if(System("bin:co -l \""+ParentName+"\"")){ // try to lock file
  73.         Request("Check out error!\n(Consult the readme for more help)","RCS request","Panic!");
  74.         reLock = 1;
  75.       } else {
  76.         Save();                                // save again (protection bits changed)
  77.         if (System("bin:ci "+lock+" \""+ParentName+"\" < "+CommentName)){ // retry Check In
  78.           Request("New attept to check in failed!\n(Consult the readme for more help)","RCS request","Panic!");
  79.           reLock = 1;
  80.         }
  81.       }
  82.     else {
  83.       Request("OK, master. Remember that your changes are not checked in!","RCS request","Panic!");
  84.       reLock = 1;
  85.     }
  86.  
  87.  
  88.   MaximizeView();                            // Make parent only view
  89.  
  90.   System("delete "+CommentName);            // Delete comment file
  91.   Clean("Kill(thisID);");                    // and the comment buffer
  92.  
  93.   if (!reLock)                                // If lock not retained
  94.     SetInfo(-1,"protectionbits", ReadInfo("protectionbits")|4);
  95.                                                 // writeprotect parent buffer
  96. }
  97.  
  98.  
  99. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» ChangeWFlag ««
  100. void export ChangeWFlag(int ReLock)
  101. {
  102.   int isRCS;
  103.   isRCS = Check(ReadInfo("full_file_name")+",v","");
  104.   isRCS = isRCS || Check(ReadInfo("file_path")+"RCS/"+ReadInfo("file_name"),"");
  105.  
  106.   if ((ReadInfo("protectionbits")&4)){
  107.     if (isRCS){
  108.       RCSCheckOut();
  109.     } else {
  110.       SetInfo(-1,"protectionbits",ReadInfo("protectionbits")&0xfffb);
  111.                                             // if not an RCS file, just alter
  112.     }                                        // the write protection flag.
  113.   } else {
  114.     if (isRCS)
  115.       EnterRCSComment(ReLock);
  116.     else {
  117.       if (Request("Should I put the file under RCS control?","RCS request","Yes|No")){
  118.         if (!Check(ReadInfo("file_path")+"RCS")){
  119.           // Ask to create RCS dir
  120.           if (Request("Do you want me to create an RCS directory?","RCS request","Yes|No")){
  121.             // Creat RCS dir
  122.             System("makedir "+ReadInfo("file_path")+"RCS");
  123.           }
  124.         }
  125.         Request("This first comment will be used for file description.\nDo not enter revision specific information!", "RCS info","Um, OK!");
  126.         EnterRCSComment(ReLock);
  127.       } else {
  128.         SetInfo(-1,"protectionbits",ReadInfo("protectionbits")|4);
  129.                                             // if not an RCS file, just alter
  130.       }                                         // the write protection flag.
  131.     }
  132.   }
  133. }
  134.  
  135.  
  136. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Make history ««
  137. export void RCSMakeHistory()
  138. {
  139.   string file = PromptFile("","Extract history from...","","");    // get file name
  140.   if (strlen(file)){
  141.     string history = file+".history";
  142.     if (Check(history)){
  143.       switch(Request("History file already exist!","RCS request","Overwrite!|New name|Cancel")){
  144.         case 2:                                // Ask new file name
  145.           history = PromptFile(history,"Select output file...","","s");
  146.           break;
  147.         case 0:                                // Cancel operation by setting empty name
  148.           history="";
  149.           break;
  150.       }
  151.     }
  152.     if (strlen(history)){                    // Only continue if name defined
  153.       int prevVisible = Visible(0);            // Disable screen update
  154.       int histID = New();                    // Get new buffer
  155.  
  156.       System("bin:rlog \""+file+"\" >"+history); // Get history created
  157.       CurrentBuffer(histID);
  158.       Load(history);                        // load history
  159.       DeleteLine(11);                        // and make history a bit more readable:
  160.       SearchSet("=of+","date:");            // Erase difference info
  161.       while (!Search("date:")){
  162.         Search(";");
  163.         DeleteEol();
  164.       }
  165.       GotoLine(1);
  166.       Save("");                                // update file to disk
  167.       Visible(prevVisible);                    // and update screen
  168.       RedrawScreen(0);
  169.     }
  170.   }
  171. }
  172.  
  173.  
  174. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Key bindings ««
  175. AssignKey("ChangeWFlag(0);","control x control q","");
  176. AssignKey("ChangeWFlag(1);","control x control Q","");
  177. AssignKey("RCSCheckIn();","control c control c", "_IsRCSBuffer");
  178. AssignKey("Clean(\"Kill();\");","control g", "_IsRCSBuffer");
  179.  
  180.  
  181. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Hidden variables ««
  182. ConstructInfo("_IsRCSBuffer","","", "LBH", "",0,1,0);
  183. ConstructInfo("_RCSReLock","","", "LBH", "",0,1,0);
  184. ConstructInfo("_RCSParentBuffer","","", "LIH", "",0,0x7fffffff,0);
  185.